*****************************************************************************
*	6502 C COMPILER FLOATING POINT INTERFACE ROUTINES.                  *
*****************************************************************************

		.linklist
		.symbols

******************************************************************************

		.MODULE	__add_float

;	ADD OPERAND #2 FLOAT POINTED TO BY (__oper2) TO OPERAND #1 FLOAT POINTED
;	TO BY (__oper1), AND STORE THE RESULT IN '__oper1_temp_store'.  RETURN
;	WITH '__oper1' POINTING TO THE RESULT.

runtime_program:  .section

		.global	__add_float
		.extern	___add_float

__add_float:	clc				;clear carry flag (addition)
		jsr	___add_float		;perform the addition
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__add_double

;	ADD OPERAND #2 DOUBLE POINTED TO BY (__oper2) TO OPERAND #1 DOUBLE
;	POINTED TO BY (__oper1), AND STORE THE RESULT IN '__oper1_temp_store'.
;	RETURN WITH '__oper1' POINTING TO THE RESULT.

runtime_program:  .section

		.global	__add_double
		.extern	___add_double

__add_double:	ldy	#0			;clear y (addition)
		jsr	___add_double		;perform the addition
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__sub_float

;	SUBTRACT OPERAND #2 FLOAT POINTED TO BY (__oper2) FROM OPERAND #1 FLOAT
;	POINTED	TO BY (__oper1), AND STORE THE RESULT IN '__oper1_temp_store'.
;	RETURN WITH '__oper1' POINTING TO THE RESULT.

runtime_program:  .section

		.global	__sub_float
		.extern	___add_float

__sub_float:	sec				;set carry flag (subtraction)
		jsr	___add_float		;perform the addition
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__sub_double

;	SUBTRACT OPERAND #2 DOUBLE POINTED TO BY (__oper2) FROM OPERAND #1
;	DOUBLE POINTED TO BY (__oper1), AND STORE THE RESULT IN
;	'__oper1_temp_store'.  RETURN WITH '__oper1' POINTING TO THE RESULT.

runtime_program:  .section

		.global	__sub_double
		.extern	___add_double

__sub_double:	ldy	#1			;set 'subtraction' flag
		jsr	___add_double		;perform the addition
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__mult_float

;	MULTIPLY OPERAND #1 FLOAT POINTED TO BY (__oper1) BY OPERAND #2
;	FLOAT POINTED TO BY (__oper2), AND STORE THE RESULT IN 
;	'__oper1_temp_store'.  RETURN WITH '__oper1' POINTING TO THE RESULT.

runtime_program:  .section

		.global	__mult_float
		.extern	___mult_float

__mult_float:	jsr	___mult_float		;perform the multiplication
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__mult_double

;	MULTIPLY OPERAND #1 DOUBLE POINTED TO BY (__oper1) BY OPERAND #2 DOUBLE
;	POINTED TO BY (__oprer2), AND STORE THE RESULT IN '__oper1_temp_store'.
;	RETURN WITH '__oper1' POINTING TO THE RESULT.

runtime_program:  .section

		.global	__mult_double
		.extern	___mult_double

__mult_double:	jsr	___mult_double		;perform the multiplication
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__div_float

;	DIVIDE OPERAND #1 FLOAT POINTED TO BY (__oper1) BY OPERAND #2 FLOAT
;	POINTED TO BY (__oper2), AND STORE THE RESULT IN
;	'__oper1_temp_store'.  RETURN WITH '__oper1' POINTING TO THE RESULT.

runtime_program:  .section

		.global	__div_float
		.extern	___div_float

__div_float:	jsr	___div_float		;perform the division
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__div_double

;	DIVIDE OPERAND #1 DOUBLE POINTED TO BY (__oper1) BY OPERAND #2 DOUBLE
;	POINTED TO BY (__oper2), AND STORE THE RESULT IN '__oper1_temp_store'.
;	RETURN WITH '__oper1' POINTING TO THE RESULT.

runtime_program:  .section

		.global	__div_double
		.extern	___div_double

__div_double:	jsr	___div_double		;perform the division
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__cmp_float_interface

;	THIS ROUTINE COMPARES OPERAND #1 FLOAT POINTED TO BY (__oper1) TO
;	OPERAND #2 FLOAT POINTED TO BY (__oper2).  THE ROUTINE RETURNS TO
;	THE CALLER WITH THE FOLLOWING CODES IN REGISTER a:
;
;		0 - EQUAL
;		1 - OPERAND #1 (d) IS LESS THAN OPERAND #2
;		2 - OPERAND #1 (d) IS GREATER THAN OPERAND #2

runtime_program:  .section

		.global	__cmp_float_interface
		.extern	___cmp_float

__cmp_float_interface:  .equal  $
		jsr	___cmp_float
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__cmp_double_interface

;	THIS ROUTINE COMPARES OPERAND #1 DOUBLE POINTED TO BY (__oper1) TO
;	OPERAND #2 DOUBLE POINTED TO BY (__oper2).  THE ROUTINE RETURNS TO
;	THE CALLER WITH THE FOLLOWING CODES IN REGISTER a:
;
;		0 - EQUAL
;		1 - OPERAND #1 (d) IS LESS THAN OPERAND #2
;		2 - OPERAND #1 (d) IS GREATER THAN OPERAND #2

runtime_program:  .section

		.global	__cmp_double_interface
		.extern	___cmp_double

__cmp_double_interface:  .equal  $
	 	jsr	___cmp_double		;perform the comparison
		rts				;return with result code in D0

		.ENDMOD

******************************************************************************

		.MODULE	__long_to_float_interface

;	CONVERT THE LONG POINTED TO BY (__oper1) TO A FLOAT.  RETURN WITH THE
;	FLOAT IN THE LOCATION POINTED TO BY __oper2.

runtime_program:  .section

		.global	__long_to_float_interface
		.extern	___long_to_float

__long_to_float_interface:  .equal  $
		jsr	___long_to_float	;perform the conversion
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__long_to_double_interface

;	CONVERT THE LONG POINTED TO BY (__oper1) TO A DOUBLE.  RETURN WITH THE
;	DOUBLE IN THE LOCATION POINTED TO BY __oper2.

runtime_program:  .section

		.global	__long_to_double_interface
		.extern	___long_to_double

__long_to_double_interface:  .equal  $
		jsr	___long_to_double	;perform the conversion
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__float_to_long_interface

;	CONVERT THE FLOAT POINTED TO BY (__oper1) TO A LONG.  RETURN WITH
;	THE LONG STORED IN THE LOCATION POINTED TO BY (__oper2).

runtime_program:  .section

		.global	__float_to_long_interface
		.extern	___float_to_long

__float_to_long_interface:  .equal  $
		jsr	___float_to_long	;perform the conversion
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__float_to_double_interface

;	CONVERT THE FLOAT POINTED TO BY (__oper1) TO A DOUBLE.  RETURN WITH
;	THE DOUBLE STORED IN THE LOCATION POINTED TO BY (__oper2).

runtime_program:  .section

		.global	__float_to_double_interface
		.extern	___float_to_double

__float_to_double_interface:  .equal  $
		jsr	___float_to_double	;perform the conversion
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__double_to_long_interface

;	CONVERT THE DOUBLE POINTED TO BY (__oper1) TO A LONG.  RETURN WITH THE 
;	LONG IN THE LOCATION POINTED TO BY __oper2.

runtime_program:  .section

		.global	__double_to_long_interface
		.extern	___double_to_long

__double_to_long_interface:  .equal  $
		jsr	___double_to_long	;perform the conversion
		rts

		.ENDMOD

******************************************************************************

		.MODULE	__double_to_float_interface

;	CONVERT THE DOUBLE POINTED TO BY (__oper1) TO A FLOAT.  RETURN WITH
;	THE DOUBLE STORED IN THE LOCATION POINTED TO BY (__oper2).

runtime_program:  .section

		.global	__double_to_float_interface
		.extern	___double_to_float

__double_to_float_interface:  .equal  $
		jsr	___double_to_float	;perform the conversion
		rts

		.ENDMOD

******************************************************************************


		.end

